# -*- coding: utf-8; mode: snippet -*-
# name: dispatch with promise (redux-thunk required)
# key: dispatch
# contributor: Chen Bin <chenbin.sh AT gmail>
# --
// copy below code into reducer.js
// case '${1:$(yas/substr yas-text "[^ ]*")}':
//   finalStoreState = { ...storeState, ${2:$(yas/substr yas-text "[^ ]*")}: action.${2:$(yas/substr yas-text "[^ ]*")} };
//   break;
this.props.dispatch(function(dispatch) {
  return postJSON('/', {
  }).then(function(resp) {
    return dispatch({
      type: '${1:EVT_SHOW_STH}',
      ${2:showSth}: true
    });
  });
}).then(function(resp) {
  console.log('data in store. resp=', resp);
});